import { defineConfig } from '@vben/vite-config';

import AutoImport from 'unplugin-auto-import/vite';

export default defineConfig(async () => {
  return {
    application: {},
    vite: {
      plugins: [
        AutoImport({
          dts: 'src/auto-imports.d.ts', // 自动生成类型声明文件
          imports: ['vue', 'vue-router', '@vueuse/core', 'pinia'],
          vueTemplate: true, // 是否在 vue 模板中自动导入
        }),
      ],
      server: {
        proxy: {
          '/api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''),
            // mock代理目标地址
            target: 'http://114.55.63.142:8010/api',
            ws: true,
          },
          '/ttt': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/ttt/, '/api'),
            target: 'http://114.55.63.142:8010/',
            ws: true,
          },
        },
      },
    },
  };
});
